﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Department.aspx.cs" Inherits="WebPresentation.Department" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style5
        {
            width: 233px;
        }
        .style6
        {
            width: 426px;
        }
    </style>
    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#MainContent_dtgdepartment td:nth-child(2), #MainContent_dtgdepartment th:nth-child(2)').hide();
            $("#MainContent_LinkButtonadd").click(function () {
                $("#add").toggle();
                $("#edit").hide();
                $("#delete").hide();
                return false;
            });
            $("#MainContent_LinkButtonedit").click(function () {
                $("#edit").toggle();
                $("#add").hide();
                $("#delete").hide();
                return false;
            });
        });
    </script>
    <link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">   
    <div align="center">
    
    <asp:Label ID="Label10" runat="server" Width="100%" ForeColor="Red" 
        Font-Bold="True"></asp:Label>
    
</div>
<br />
<div>
    <table style="width: 100%;">
        <tr>
            <td align="center" width="33%">
                &nbsp;
                <asp:LinkButton ID="LinkButtonadd" runat="server">Add new record</asp:LinkButton>
            </td>
            <td align="center" width="34%">
                <asp:LinkButton ID="LinkButtonedit" runat="server" 
                    onclick="LinkButtonedit_Click">Edit record</asp:LinkButton>
                &nbsp;
            </td>
            <td align="center" width="33%">
                
                <asp:LinkButton ID="LinkButtondel" runat="server" onclick="LinkButtondel_Click">Delete record</asp:LinkButton>
                
            </td>
        </tr>
    </table>
</div>
<br />
<div id="add" class="nodisplay">
<fieldset>
    <legend>Department:</legend>
    <table style="width: 100%;">
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Department Name:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="center" class="style5">
                <asp:TextBox ID="txtdepname" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                    <br />
            </td>
        </tr>
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department Code:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="center" class="style5">
                <asp:TextBox ID="txtdepcode" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                    <br />
            </td>
        </tr>
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label11" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
            <td align="center" class="style5">
                &nbsp;</td>
            <td align="center">
                &nbsp;</td>
        </tr>
    </table>
    <br />
    <div align="center">
        <asp:ImageButton ID="ImageButtonadd" runat="server" 
            ImageUrl="~/Images/addbutton.png" onclick="ImageButtonadd_Click" />
    </div>
</fieldset>
</div>
<div id="edit" class="nodisplay">
<fieldset>
    <legend>Department:</legend>
    <table style="width: 100%;">
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Department Name:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="center" class="style5">
                <asp:TextBox ID="txtNameEdit" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ErrorMessage="Please input department!" ControlToValidate="txtNameEdit" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ErrorMessage="Invalid input!" ControlToValidate="txtNameEdit" 
                    ForeColor="Red" ValidationExpression="^[a-zA-Z'.\s]{1,40}$"></asp:RegularExpressionValidator>--%>
            </td>
        </tr>
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="Department Code:" 
                    Width="150px" style="text-align:left"></asp:Label>
            </td>
            <td align="center" class="style5">
                <asp:TextBox ID="txtCodeEdit" runat="server" Width="170px"></asp:TextBox>
            </td>
            <td align="center">
                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ErrorMessage="Please input code!" ControlToValidate="txtCodeEdit" 
                    ForeColor="Red"></asp:RequiredFieldValidator>
                    <br />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                    ErrorMessage="Invalid Input" ControlToValidate="txtCodeEdit" 
                    ForeColor="Red" ValidationExpression="^[a-zA-Z0-9'.\s]{1,40}$"></asp:RegularExpressionValidator>--%>
            </td>
        </tr>
        <tr>
            <td align="right" class="style6">
                <asp:Label ID="Label5" runat="server" Text="Label" Visible="False"></asp:Label>
            </td>
            <td align="center" class="style5">
                &nbsp;</td>
            <td align="center">
                &nbsp;</td>
        </tr>
    </table>
    <br />
    <div align="center">
        <asp:ImageButton ID="ImageButtonedit" runat="server" 
            ImageUrl="~/Images/editbutton.png" onclick="ImageButtonedit_Click" />
    </div>
</fieldset>
</div>
<fieldset>
    <legend>Details:</legend>
    <div>
        
        <asp:GridView ID="dtgdepartment" runat="server" CellPadding="4" 
            ForeColor="#333333" GridLines="None" Width="100%" 
            AutoGenerateColumns="False" AutoGenerateSelectButton="True" 
            DataKeyNames="depID" DataSourceID="DepDataSource" 
            onselectedindexchanged="dtgdepartment_SelectedIndexChanged" 
            style="text-align: center" AllowPaging="True">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="depID" HeaderText="depID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="depID" >
                <ItemStyle CssClass="hiddenField" />
                </asp:BoundField>
                <asp:BoundField DataField="depName" HeaderText="Department" 
                    SortExpression="depName" />
                <asp:BoundField DataField="depCode" HeaderText="Code" 
                    SortExpression="depCode" />
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        
        <asp:ObjectDataSource ID="DepDataSource" runat="server" 
            DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDepartments" 
            TypeName="BusinessLogic.DepartmentBO" UpdateMethod="UpdateDepartment">
            <DeleteParameters>
                <asp:Parameter Name="depID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="depName" Type="String" />
                <asp:Parameter Name="depCode" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="depName" Type="String" />
                <asp:Parameter Name="depCode" Type="String" />
                <asp:Parameter Name="depID" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
        
    </div>
</fieldset>
</asp:Content>
